package com.flatlyapps.shoppinglist;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

public class ShoppingList {

	private BigDecimal funds;
	private List<ShoppingItem> items;
	private Integer listId;
	private int colour;
	private Date date;
	private String listName;
	private String currency;

	public ShoppingList(Integer listId, BigDecimal funds, int colour, Date date, String currency, String listName, List<ShoppingItem> items){
		this.listId = listId;
		this.funds = funds;
		this.items = items;
		this.colour = colour;
		this.date = date;
		this.listName = listName;
		this.currency = currency;
	}

	public void setFunds(BigDecimal funds) {
		this.funds = funds;
	}

	public BigDecimal getFunds() {
		return funds;
	}

	public List<ShoppingItem> getItems() {
		return items;
	}

	public void setItems(List<ShoppingItem> items) {
		this.items = items;
	}

	public Integer getListId() {
		return listId;
	}

	public void addItem(ShoppingItem item){
		items.add(0, item);
	}

	public void remove(long itemId) {
		for(ShoppingItem item: items){
			if(item.getId() == itemId){
				items.remove(item);
				break;
			}
		}
	}

	public ShoppingItem getItem(long itemId) {
		for(ShoppingItem item: items){
			if(item.getId() == itemId){
				return item;
			}
		}
		return null;
	}

	public int getColour() {
		return colour;
	}

	public void setColour(int colour) {
		this.colour = colour;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public Date getDate(){
		return date;
	}

	public void setListName(String newName) {
		this.listName = newName;
	}

	public String getListName(){
		return listName;
	}

	public String getCurrency() {
		return currency;
	}

	public void setCurrency(String currency) {
		this.currency = currency;
	}
}
